home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13423 < prev    next >
Encoding:
Text File  |  1996-08-05  |  888 b   |  40 lines

  1. Path: news.kreonet.re.kr!usenet
  2. From: Parao@kyebek.kjist.ac.kr (Don Kim)
  3. Newsgroups: comp.lang.c
  4. Subject: [QE] : file open problem
  5. Date: 7 Apr 1996 15:22:18 GMT
  6. Organization: Kwang-ju institute of Science & Technology
  7. Message-ID: <4k8mja$ddn@news.kreonet.re.kr>
  8. NNTP-Posting-Host: kyebek5.kjist.ac.kr
  9. Mime-Version: 1.0
  10. Content-Type: Text/Plain; charset=US-ASCII
  11. X-Newsreader: WinVN 0.99.7
  12.  
  13. Hello, there
  14.  
  15. I have a problem with file opening.
  16. In my code,
  17.  
  18.     saveTextToFile ( char *text, char *filename)    {
  19.     FILE *file;
  20.  
  21.     if ( ( file = fopen (filename, "w") = = NULL ) 
  22.         cout << "Cannot open file" << endl;
  23.     else    {
  24.         (void) fprintf (file, "%s\n", text);
  25.         (void) fclose(file);
  26.     }
  27.    }
  28.  
  29.    :
  30.    :
  31.  
  32.    char *_type = "part";    
  33.    saveTextToFile ( _type, _type );
  34.  
  35. Is anything wrong in my source code ? My program always displays "Cannot 
  36. open file"....
  37.  
  38. Let me know how to fix the problem.
  39.  
  40.